﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace DefaulArchitecture.Exception
{
    public sealed class DALException : System.Exception
    {
        #region Attributes

        private string baseDAOMethod;
        private string daoName;
        private string daoMethod;

        #endregion

        #region Constructors

        /// <summary>
        /// Starts DAOException.
        /// </summary>
        /// <param name="message">Exception message</param>
        /// <param name="daoName">DAO witch throws the exception</param>
        /// <param name="daoMethod">DAO method witch throws the exception</param>
        public DALException(string message, string daoName, string daoMethod)
            : base(message)
        {
            this.baseDAOMethod = null;
            this.daoName = daoName;
            this.daoMethod = daoMethod;
        }

        /// <summary>
        /// Starts DAOException.
        /// </summary>
        /// <param name="message">Exception message</param>
        /// <param name="baseDAOMethod">BaseDAO method witch throws the exception</param>
        public DALException(string message, string baseDAOMethod)
            : base(message)
        {
            this.baseDAOMethod = baseDAOMethod;
            this.daoName = null;
            this.daoMethod = null;
        }

        #endregion

        #region Properties

        /// <summary>
        /// Returns if is an BaseDAO Exception
        /// </summary>
        public bool IsFromBaseDAO
        {
            get { return baseDAOMethod != null; }
        }

        /// <summary>
        /// Returns BaseDAO method that throws the exception
        /// </summary>
        public string BaseDAOMethod
        {
            get { return baseDAOMethod; }
        }

        /// <summary>
        /// Returns the name of the DAO that throws the exception
        /// </summary>
        public string DAOName
        {
            get { return daoName; }
            set { daoName = value; }
        }

        /// <summary>
        /// Returns the name of the method that throws the exception
        /// </summary>
        public string DAOMethod
        {
            get { return daoMethod; }
            set { daoMethod = value; }
        }

        #endregion
    }
}
